<template>
  <a-select
    :value="value"
    style="width: 100%"
    placeholder="请选择"
    :allow-clear="true"
    :disabled="disabled || !versionDisabled"
    @select="OnSelect"
  >
    <template v-for="(item, index) in mouldList">
      <a-select-option :key="item.id" :value="item.id" :label="item.name">
        {{ item.name }}
      </a-select-option>
    </template>
  </a-select>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'

export default {
  name: 'AreaSelect',
  props: {
    value: [Number, String],
    placeholder: {
      type: String,
      default: '请选择',
      required: false
    },
    disabled: {
      type: Boolean,
      required: false,
      default: false
    },
    versionDisabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      url: {
        list: '/sjtb/dataCollectionTemplateInfo/getDict'
      },
      mouldList: []
    }
  },
  created() {
    this.getMouldList()
  },
  methods: {
    OnSelect(value) {
      this.$emit('input', value)
      this.$emit('change', value)
    },
    getMouldList() {
      getAction(this.url.list).then((res) => {
        if (res.success) {
          this.mouldList = res.result
        } else {
          console.log(res)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
